﻿import QtQuick 2.11
//import QtQuick.Controls 1.4
import QtQuick.Controls 2.2

import com.leamus.gamedata 1.0

import "."
import "_Global"

import "_Global/Global.js" as GlobalJS
import "GameJS.js" as GameJS

Item {

    signal debugGameManager(int value,var param)   //发送给C++Manager窗口的调试信息
    signal debugGameCore(int type, var v)     //发送给C++GameCore的调试信息
    signal debugGameWindow(int value,var param)   //发送给Qml game.qml的窗口的调试信息
    signal debugGameUI(int value,var param)   //发送给Qml GameUI.qml游戏窗口的调试信息


    function showDebugMsg(msg) {       //接受游戏窗口的调试信息
        debugMsg.appendText(msg);
    }


    id: debugWindow
    objectName: "debugWindow"
    anchors.fill: parent
    //title: qsTr("英语杀调试窗口")
    visible: true



    MsgBox {
        id: debugMsg
        x: 0
        z: 0.1
        width: Global.dpW(400)
        height: parent.height
        anchors.right: parent.right
        //enabled: false

        //z: 3

        Component.onCompleted: {
            //appendText().connect
        }
    }

    Button {
        id: debug1
        x: Global.dpW(0); y: Global.dpH(0); z: 10
        width: Global.dpW(150); height: Global.dpH(100)
        text: "牌堆"

        contentItem: Label {
            renderType: Text.NativeRendering
            verticalAlignment: Text.AlignVCenter
            horizontalAlignment: Text.AlignHCenter
            //font.family: "Helvetica"
            font.pixelSize: Global.dpH(25)
            color: "blue"
            text: parent.text
        }

        onClicked: debugGameCore(10,null)
    }
    Button {
        id: debug2
        x: Global.dpW(150); y: Global.dpH(0); z: 10
        width: Global.dpW(150); height: Global.dpH(100)
        text: "弃牌堆"
        contentItem: Label {
            font.pixelSize: Global.dpH(25)
            text: parent.text
        }
        onClicked: debugGameCore(11,null)
    }

    Button {
        id: debug3;
        x: Global.dpW(300); y: Global.dpH(0); z: 10
        width: Global.dpW(150); height: Global.dpH(100)
        text: "player手牌"
        contentItem: Label {
            font.pixelSize: Global.dpH(25)
            text: parent.text
        }
        onClicked: debugGameCore(12,getPlayerAllPai.text)
    }

    TextField {
        id: getPlayerAllPai
        x: Global.dpW(450); y: Global.dpH(0); z: 10
        width: Global.dpW(150); height: Global.dpH(100)
        text: "0"
        selectByMouse: true
        font.pixelSize: Global.dpH(25)
    }

    Button {
        id: debug5
        x: Global.dpW(600); y: Global.dpH(0); z: 10
        width: Global.dpW(150); height: Global.dpH(100)
        text: "刷新"
        contentItem: Label {
            font.pixelSize: Global.dpH(25)
            text: parent.text
        }
        onClicked: debugGameCore(14,null)
    }

    Button {
        x: Global.dpW(750); y: Global.dpH(0); z: 10
        width: Global.dpW(150); height: Global.dpH(100)
        text: "游戏结束"
        contentItem: Label {
            font.pixelSize: Global.dpH(25)
            text: parent.text
        }
        onClicked: debugGameCore(20,null)
    }

    Button {
        x: Global.dpW(900); y: Global.dpH(0); z: 10
        width: Global.dpW(150); height: Global.dpH(100)
        text: "断开socket"
        contentItem: Label {
            font.pixelSize: Global.dpH(25)
            text: parent.text
        }
        onClicked: debugGameCore(30,null)
    }

    Button {
        x: Global.dpW(1050); y: Global.dpH(0); z: 10
        width: Global.dpW(150); height: Global.dpH(100)
        text: "速度调整"
        contentItem: Label {
            font.pixelSize: Global.dpH(25)
            text: parent.text
        }
        onClicked: {
            //Global.config.nQuestionChoiceDelay = 50
            Global.config.nQuestionShowDelay = 500
            Global.config.nComQuestionChoiceDelay = 500

            debugGameCore(40,null);

        }
    }

    Button {
        x: 0; y: Global.dpH(100); z: 10
        width: Global.dpW(150); height: Global.dpH(100)
        text: "得到牌"
        contentItem: Label {
            font.pixelSize: Global.dpH(25)
            text: parent.text
        }
        onClicked: debugGameCore(15,getPaiId.text)
    }

    TextField {
        id: getPaiId
        x: Global.dpW(150); y: Global.dpH(100); z: 10
        width: Global.dpW(150); height: Global.dpH(100)
        font.pixelSize: Global.dpH(25)
        selectByMouse: true
        text: "101"
    }

    Button {
        x: Global.dpW(300)
        y: Global.dpH(100)
        width: Global.dpW(150); height: Global.dpH(100)
        //width: 70
        //height: 20
        text: "socket"
        contentItem: Label {
            font.pixelSize: Global.dpH(25)
            text: parent.text
        }
        onClicked: {
            debugGameManager(10,null)
        }
    }

    Button {
        x: Global.dpW(450)
        y: Global.dpH(100)
        width: Global.dpW(150); height: Global.dpH(100)
        text: "发送"
        contentItem: Label {
            font.pixelSize: Global.dpH(25)
            text: parent.text
        }
        onClicked: {
            debugGameManager(20,null)
        }
    }

    Button {
        x: Global.dpW(600)
        y: Global.dpH(100)
        width: Global.dpW(150); height: Global.dpH(100)
        text: "发送2"
        contentItem: Label {
            font.pixelSize: Global.dpH(25)
            text: parent.text
        }
        onClicked: {
            debugGameManager(21,null)
        }
    }

    Button {
        x: Global.dpW(750)
        y: Global.dpH(100)
        width: Global.dpW(150); height: Global.dpH(100)
        text: GameManager.userInfo.flagCorrectAnswer ? qsTr("关闭学习卡") : qsTr("打开学习卡")

        contentItem: Label {
            font.pixelSize: Global.dpH(25)
            text: parent.text
        }
        onClicked: {
            GameManager.userInfo.flagCorrectAnswer = !GameManager.userInfo.flagCorrectAnswer
            console.debug("学习卡:",GameManager.userInfo.flagCorrectAnswer)
        }
    }

    Button {
        x: Global.dpW(900)
        y: Global.dpH(100)
        width: Global.dpW(150); height: Global.dpH(100)
        text: GameManager.userInfo.canReview ? qsTr("关闭复习卡") : qsTr("打开复习卡")

        contentItem: Label {
            font.pixelSize: Global.dpH(25)
            text: parent.text
        }
        onClicked: {
            GameManager.userInfo.canReview = !GameManager.userInfo.canReview
            console.debug("复习卡:",GameManager.userInfo.canReview)
        }
    }

    Button {
        x: Global.dpW(1050)
        y: Global.dpH(100)
        width: Global.dpW(150); height: Global.dpH(100)
        text: "链接服务器"
        contentItem: Label {
            font.pixelSize: Global.dpH(25)
            text: parent.text
        }
        onClicked: {
            debugGameManager(22,null)
        }
    }

    Button {
        x: Global.dpW(1200)
        y: Global.dpH(100)
        width: Global.dpW(150); height: Global.dpH(100)
        text: "托管"
        contentItem: Label {
            font.pixelSize: Global.dpH(25)
            text: parent.text
        }
        onClicked: {
            debugGameManager(23,null)
        }
    }




    Text {
        id: com
        x: Global.dpW(0)
        y: Global.dpH(200)
        text: "玩家数"
    }

    TextField {
        id: computerCount
        x: Global.dpW(150)
        y: Global.dpH(200)
        width: Global.dpW(150); height: Global.dpH(100)
        //color: "#ffffff"
        //autoScroll: false
        //echoMode: TextInput.Password
        //cursorVisible: true
        //antialiasing: true
        font.pixelSize: Global.dpH(25)
        selectByMouse: true
        text: "2"
    }

    Label {
        id: label
        x: Global.dpW(300)
        y: Global.dpH(200)
        width: 68
        height: 12
        text: qsTr("<a>游戏试玩</a>")

        MouseArea {
            id: mouseSingle
            anchors.fill: parent
            onClicked: debugGameWindow(1,computerCount.text)
        }
    }

    TextField {
        id: temp
        x: Global.dpW(450)
        y: Global.dpH(200)
        width: 199
        height: 24
        selectByMouse: true
        text: qsTr("")
    }

    Component.onCompleted: {
    }

}
